package written.test;

import java.util.Scanner;

/**
 * @Author: Dang Qi
 * @Date: 2021/4/18  16:18
 * @Description:
 */
public class Wangyi2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n ; i++) p[i] = sc.nextInt();

        int[][] dp = new int[n][n];
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++){
            for(int j = i; j < n; j++){
                if(i == j) dp[i][j] = p[i];
                else if((j-i)%2==0){
                    dp[i][j] = dp[i][j-1] + p[j];
                }else{
                    dp[i][j] = dp[i][j-1] - p[j];
                }
                max = Math.max(max, dp[i][j]);
            }
        }
        if(max<0) max =0;
        System.out.println(max);

    }

    public int[][] search_log (long[][] logs, long[] tss) {
        // write code here
        return null;
    }
}
